#include <iostream>
#include "boost/asio.hpp"
#include "CServer.h"
#include <memory>
#include "ConfigMgr.h"
#include "RedisMgr.h"
#include "MysqlMgr.h"



int main()
{
    auto& config_mgr = ConfigMgr::GetInstance();
    //初始化Mysql连接池
    MysqlMgr::GetInstance();
    
    
    //初始化Redis连接池
    RedisMgr::GetInstance();

    boost::asio::io_context io_context;
    std::make_shared<CServer>(io_context,atoi(config_mgr["GateServer"]["Port"].c_str()))->Start();
    //优雅退出
    boost::asio::signal_set signals(io_context,SIGINT,SIGTERM);
    signals.async_wait([&io_context](boost::system::error_code, int signo){
        std::cerr<<"signal "<<signo<<" received,exit..."<<std::endl;
        io_context.stop();
    });


    io_context.run();
    return 0;
}
